package com.learn.ch02ttlqueue.other;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/08/27
 * @description ch09 other
 */
@Configuration
public class RabbitOtherConfig {
    @Bean
    public DirectExchange exchangeOther() {
        return new DirectExchange("exchangeOther");
    }
    @Bean
    public Queue queueOther() {
        Map<String, Object> arguments = new HashMap<>(2);
        // 优先队列
        arguments.put("x-max-priority", 10);
        // 惰性队列
        arguments.put("x-queue-mode", "lazy");
       return QueueBuilder.durable("queueOther").withArguments(arguments).build();
    }
    @Bean
    public Binding bindingOther(@Qualifier("exchangeOther") DirectExchange exchange,
                                @Qualifier("queueOther") Queue queue) {
        return BindingBuilder.bind(queue).to(exchange).with("other");
    }
}
